export const useTts = defineStore('tts', () => {
  const text = ref('')
  // 设置tts文本
  const setText = (val: string) => {
    text.value = val
  }

  const ttsVisible = ref(false)
  // 设置tts播放按钮是否可见
  const setTtsVisible = (val: boolean) => {
    ttsVisible.value = val
  }

  return {
    text,
    setText,
    ttsVisible,
    setTtsVisible,
  }
})
// 从html中提取文本
export function getTextFromHtml(html: string) {
  const parser = new DOMParser()
  const doc = parser.parseFromString(html, 'text/html')

  const text = doc.body.textContent || ''
  return text
}
